#ifndef RTMPSENDTASK_H
#define RTMPSENDTASK_H

#include "Receive_handler.h"
#include "Task_Base/Task_Base.h"
class RtmpMuxerImpl;
class BleTimestampBulider;
class MStream;
class AVPacket;
class AsynchExecTask;
class RtmpSendTask: public Task_Base ,public Receive_handler
{
public:
    RtmpSendTask();
    ~RtmpSendTask();
public:
    void set_url(const std::string &url);
	void set_event_handle(AsynchExecTask*);
    void Init(std::string & VideoSh,std::string &VideoSei,std::string &AudioSh);
public:
    virtual int close();
    virtual bool receive_handler(const char *data,int size);
protected:
    virtual int svc();//主动工作线程函数
	void releaseAvPacket();
    int service(RtmpMuxerImpl & muxer);
private:
    int sendMetadata(RtmpMuxerImpl &muxer, MStream &body);
private:
    std::string   m_oUrl;
    RtmpMuxerImpl *m_rtmp_muxer;
	AsynchExecTask*m_oEvent;

    int m_audio_send_bytes;
    int m_video_send_bytes;
    long long m_data_send_bytes;

    AVPacket *videoSH;
    AVPacket *audioSH;
    int m_fps;
};

#endif // RTMPSENDTASK_H
